/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * SharkFrame.java
 *
 * Created on 05/12/2010, 01:24:26
 */

package sharkorganizer;

//import java.awt.Color;
import javax.swing. *;
import java.util. *;
import java.io. *;
import java.awt.Dimension;

/**
 *
 * @author André Sales
 */
public class SharkFrame extends javax.swing.JFrame {

    /** Creates new form SharkFrame */
    static DefaultListModel model1 = new DefaultListModel();
    static LinkedList<No> lista = new LinkedList<No>();

    public SharkFrame() {
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jFrame1 = new javax.swing.JFrame();
        jPanel2 = new javax.swing.JPanel();
        jButton4 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jLabel4 = new javax.swing.JLabel();
        jFormattedTextField1 = new javax.swing.JFormattedTextField();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jFormattedTextField2 = new javax.swing.JFormattedTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        jFormattedTextField3 = new javax.swing.JFormattedTextField();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        mainPanel = new javax.swing.JPanel();
        jPanel1 = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        menuBar = new javax.swing.JMenuBar();
        javax.swing.JMenu fileMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem exitMenuItem = new javax.swing.JMenuItem();
        javax.swing.JMenu helpMenu = new javax.swing.JMenu();
        javax.swing.JMenuItem aboutMenuItem = new javax.swing.JMenuItem();

        jFrame1.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance().getContext().getResourceMap(SharkFrame.class);
        jFrame1.setTitle(resourceMap.getString("jFrame1.title")); // NOI18N
        jFrame1.setAlwaysOnTop(true);
        jFrame1.setMinimumSize(new java.awt.Dimension(700, 380));
        jFrame1.setName("jFrame1"); // NOI18N
        jFrame1.setResizable(false);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jPanel2.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 11), resourceMap.getColor("jPanel2.border.titleColor"))); // NOI18N
        jPanel2.setName("jPanel2"); // NOI18N

        jButton4.setText(resourceMap.getString("jButton4.text")); // NOI18N
        jButton4.setName("jButton4"); // NOI18N
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        jTextField1.setText(resourceMap.getString("jTextField1.text")); // NOI18N
        jTextField1.setName("jTextField1"); // NOI18N

        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Valor Unitário", "Conta s/ Valor Inicial", "Conta c/ Valor Inicial" }));
        jComboBox1.setToolTipText(resourceMap.getString("jComboBox1.toolTipText")); // NOI18N
        jComboBox1.setName("jComboBox1"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jFormattedTextField1.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00"))));
        jFormattedTextField1.setName("jFormattedTextField1"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
        jLabel9.setName("jLabel9"); // NOI18N

        jFormattedTextField2.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter(new java.text.DecimalFormat("#0.00"))));
        jFormattedTextField2.setName("jFormattedTextField2"); // NOI18N

        jLabel10.setForeground(resourceMap.getColor("jLabel10.foreground")); // NOI18N
        jLabel10.setText(resourceMap.getString("jLabel10.text")); // NOI18N
        jLabel10.setName("jLabel10"); // NOI18N

        jLabel11.setText(resourceMap.getString("jLabel11.text")); // NOI18N
        jLabel11.setName("jLabel11"); // NOI18N

        jFormattedTextField3.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.NumberFormatter()));
        jFormattedTextField3.setText(resourceMap.getString("jFormattedTextField3.text")); // NOI18N
        jFormattedTextField3.setName("jFormattedTextField3"); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jLabel7)
                        .addGap(24, 24, 24)
                        .addComponent(jLabel8, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jFormattedTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                            .addContainerGap()
                            .addComponent(jLabel10, javax.swing.GroupLayout.DEFAULT_SIZE, 424, Short.MAX_VALUE))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addComponent(jLabel3))
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addComponent(jLabel2))
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addContainerGap()
                                    .addComponent(jLabel4)))
                            .addGap(29, 29, 29)
                            .addComponent(jLabel11, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 94, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                    .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                        .addComponent(jLabel9)
                                        .addGroup(jPanel2Layout.createSequentialGroup()
                                            .addComponent(jLabel6)
                                            .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                            .addComponent(jFormattedTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 70, javax.swing.GroupLayout.PREFERRED_SIZE))))
                                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addComponent(jComboBox1, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                    .addComponent(jTextField1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 251, Short.MAX_VALUE)))
                            .addGap(23, 23, 23))
                        .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel2Layout.createSequentialGroup()
                            .addGap(14, 14, 14)
                            .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 77, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGap(42, 42, 42))))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGap(9, 9, 9)
                .addComponent(jLabel10, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel2))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel3))
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jFormattedTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(jLabel6)
                    .addComponent(jLabel11)
                    .addComponent(jFormattedTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jLabel7)
                            .addComponent(jFormattedTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel8))
                        .addGap(24, 24, 24)
                        .addComponent(jButton4))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(1, 1, 1)
                        .addComponent(jLabel9)))
                .addContainerGap(24, Short.MAX_VALUE))
        );

        jButton5.setText(resourceMap.getString("jButton5.text")); // NOI18N
        jButton5.setName("jButton5"); // NOI18N

        jButton6.setText(resourceMap.getString("jButton6.text")); // NOI18N
        jButton6.setName("jButton6"); // NOI18N

        jButton7.setText(resourceMap.getString("jButton7.text")); // NOI18N
        jButton7.setName("jButton7"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        jList1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jList1.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("jList1.border.titleFont"), resourceMap.getColor("jList1.border.titleColor"))); // NOI18N
        jList1.setModel(model1);
        jList1.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION);
        jList1.setName("jList1"); // NOI18N
        jScrollPane1.setViewportView(jList1);
        jList1.getAccessibleContext().setAccessibleParent(jFrame1);

        javax.swing.GroupLayout jFrame1Layout = new javax.swing.GroupLayout(jFrame1.getContentPane());
        jFrame1.getContentPane().setLayout(jFrame1Layout);
        jFrame1Layout.setHorizontalGroup(
            jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jFrame1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(jFrame1Layout.createSequentialGroup()
                        .addComponent(jButton5)
                        .addGap(18, 18, 18)
                        .addComponent(jButton6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton7))
                    .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 156, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jFrame1Layout.setVerticalGroup(
            jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jFrame1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jFrame1Layout.createSequentialGroup()
                        .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(15, 15, 15)
                        .addGroup(jFrame1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(jButton7)
                            .addComponent(jButton6)
                            .addComponent(jButton5))))
                .addContainerGap(21, Short.MAX_VALUE))
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle(resourceMap.getString("Form.title")); // NOI18N
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setName("Form"); // NOI18N
        setResizable(false);

        mainPanel.setName("mainPanel"); // NOI18N

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("jPanel1.border.title"))); // NOI18N
        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setOpaque(false);

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
        jButton2.setName("jButton2"); // NOI18N

        jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N
        jButton3.setName("jButton3"); // NOI18N

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(jButton1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(jButton2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addComponent(jButton3))
                .addContainerGap(18, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 21, Short.MAX_VALUE)
                .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        jLabel1.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
        jLabel1.setIcon(resourceMap.getIcon("jLabel1.icon")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        javax.swing.GroupLayout mainPanelLayout = new javax.swing.GroupLayout(mainPanel);
        mainPanel.setLayout(mainPanelLayout);
        mainPanelLayout.setHorizontalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(46, 46, 46)
                .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 320, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(37, Short.MAX_VALUE))
        );
        mainPanelLayout.setVerticalGroup(
            mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(mainPanelLayout.createSequentialGroup()
                .addGroup(mainPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 384, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(118, Short.MAX_VALUE))
        );

        menuBar.setName("menuBar"); // NOI18N

        fileMenu.setText(resourceMap.getString("fileMenu.text")); // NOI18N
        fileMenu.setName("fileMenu"); // NOI18N

        javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance().getContext().getActionMap(SharkFrame.class, this);
        exitMenuItem.setAction(actionMap.get("quit")); // NOI18N
        exitMenuItem.setText(resourceMap.getString("exitMenuItem.text")); // NOI18N
        exitMenuItem.setName("exitMenuItem"); // NOI18N
        fileMenu.add(exitMenuItem);

        menuBar.add(fileMenu);

        helpMenu.setText(resourceMap.getString("helpMenu.text")); // NOI18N
        helpMenu.setName("helpMenu"); // NOI18N

        aboutMenuItem.setAction(actionMap.get("showAboutBox")); // NOI18N
        aboutMenuItem.setName("aboutMenuItem"); // NOI18N
        helpMenu.add(aboutMenuItem);

        menuBar.add(helpMenu);

        setJMenuBar(menuBar);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(mainPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(mainPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    public void setModelo (LinkedList<No> lista) {
        for (int i = 0; i < lista.size(); i++) {
            model1.addElement(lista.get(i).nick());
        }
    }
    public void addModelo (String ent) {
        model1.addElement(ent);
    }
    public void delModelo (int val) {
        model1.remove(val);
    }
    public void delLModelo () {
        model1.remove(model1.getSize() - 1);
    }
    public void clearModel () {
        model1.clear();
    }

    static public boolean ehNumerico(String string) {
        boolean result = false;
        try {
            int num = Integer.parseInt(string);
            result = true;
        }
        catch(NumberFormatException ex) {
            result = false;
        }
        return result;
    }

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        jFrame1.setVisible(true);
}//GEN-LAST:event_jButton1ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        model1.addElement(jTextField1.getText());
        No no = new No();
        int type = jComboBox1.getSelectedIndex();
        //double cB = (double)jFormattedTextField1.getValue();
        //no.setValores(jTextField1.getText(), type, cB , WIDTH, WIDTH);
        lista.add(no);
    }//GEN-LAST:event_jButton4ActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        /*java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new SharkFrame().setVisible(true);
            }
        });*/

        //iniciando variaveis e objetos
        //JPanel pane = new JPanel();
        JScrollPane scrollPane = new javax.swing.JScrollPane();
        JList list = new javax.swing.JList();
        JFrame frame = new JFrame();
        //JLabel label1 = new JLabel();
        boolean chave = true;
        boolean cnovo = true;
        String coma = ""; //linha que recebe a entrada do usuario, e objeto para entrada abaixo
        Verificador ver = new Verificador(); //verificador de tipos
        boolean salvo = true;
        BufferedReader comando = new BufferedReader(new InputStreamReader(System.in));
        String arquivo = "";

        //visualizador
        list.setModel(model1); //seta model para a lista do painel
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setTitle("Visualizador - Shark Organizer");
        frame.setResizable(false);
        frame.setSize(450, 600);
        frame.setMinimumSize(new Dimension(450, 600));
        frame.setAlwaysOnTop(true);
        //frame.getContentPane().add(pane);
        frame.getContentPane().add(scrollPane); //adiciona scrollPane dentro do container de frame
        scrollPane.setViewportView(list); //colocar a lista dentro do painel
        //pane.add(label1);
        //pane.setBounds(0, 0, 450, 100);
        //pane.setOpaque(false);
        //label1.setForeground(Color.blue);
        //label1.setText("|Nome do Componente|  Tipo|  Custo Base|  Frequência|  Preço|");
        frame.pack();
        frame.setVisible(true);

        //teste
        //model1.addElement("Panela   |");
        //model1.addElement("Panela de pressão   |");

        //inicio do prompt
        System.out.println("Bem vindo ao Shark Organizer in Terminal ### by: André Sales de Sousa ###");
        while (chave) { //laço do programa
            if (lista.size() == 0) salvo = true;
            System.out.println("Digite a sua opção:(1 para \"Novo orçamento\", 2 para \"Carregar Orçamento\" e 3 para \"Sair\"");
            try {
                coma = comando.readLine();
            }
            catch (IOException e){
                 System.out.println("Erro: "+e.toString());
            }
            if (!ver.ehInt(coma)) { System.out.println("Entrada invalida, tente novamente."); continue;} //verifica se entrada eh valida
            switch (Integer.parseInt(coma)) { //transforma o string em int
                case 1: //novo orçamento
                    System.out.println("Você está em Novo Orçamento!");
                    cnovo = true;
                    while (cnovo) { //laço de novo orçamento NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN
                        System.out.println("Digite a opção para Novo Orçamento:");
                        System.out.println("1 para \"Adicionar Componente do Orçamento\", 2 para \"Deletar Valor da Lista\", 3 para \"Editar Valor\",");
                        System.out.println("4 para \"Salvar Orçamento\", 5 para \"Calcular Orçamento\" e 6 para \"Voltar ao Menu Inicial\"");
                        try {
                            coma = comando.readLine();
                        }
                        catch (IOException e){
                            System.out.println("Erro: "+e.toString());
                            continue;
                        }
                        if (!ver.ehInt(coma)) { System.out.println("Entrada invalida, tente novamente."); continue;} //verifica se entrada eh valida
                        switch (Integer.parseInt(coma)) {
                            case 1: //adicionar componente do orçamento ++++++++++++++++++++++++++
                                System.out.println("Digite os valores do novo componente:");
                                System.out.println("|nome do campo| tipo do campo| custo base| frequência| preço|");
                                try {
                                    coma = comando.readLine();
                                }
                                catch (IOException e){
                                    System.out.println("Erro: "+e.toString());
                                    continue;
                                }
                                if (!ver.taLegal(coma)) { //verifica se a entrada eh valida
                                    System.out.println("Entrada invalida, tente novamente.");
                                    break;
                                }
                                StringTokenizer token = new StringTokenizer(coma); //tokenizer para pegar as partes da string
                                No no = new No(); //novo no e setando valores abaixo
                                no.setValores(token.nextToken(), Integer.parseInt(token.nextToken()), Double.parseDouble(token.nextToken()), Double.parseDouble(token.nextToken()), Double.parseDouble(token.nextToken()));
                                lista.add(no); //adiciona na lista de componentes
                                model1.addElement(String.valueOf(lista.indexOf(no) + 1) + "°:  " + no.nick() + " | " + String.valueOf(no.valor()) + " | " + String.valueOf((no.custos())[0]) + " | " + String.valueOf((no.custos())[1]) + " | " + String.valueOf((no.custos())[2])); //adiciona no visualizador
                                salvo = false;
                                break;
                            case 2: //deleta um coponente do orçamento -----------------------------
                                System.out.println("Digite o valor do componente a ser deletado:");
                                try {
                                    coma = comando.readLine();
                                }
                                catch (IOException e){
                                    System.out.println("Erro: "+e.toString());
                                    continue;
                                }
                                if (!ver.ehInt(coma)) { System.out.println("Entrada invalida, tente novamente."); continue;} //verifica se entrada eh valida
                                //se numero passado pelo usuario for menor q 1 ou maior q tamanho da lista, diz que esta errado e retorna
                                if (Integer.parseInt(coma) > lista.size() || Integer.parseInt(coma) < 1) { System.out.println("Entrada fora dos limites, tente novamente."); continue; }
                                lista.remove(Integer.parseInt(coma)); //remove no da lista referenciado por coma
                                if (model1.isEmpty() == false) { 
                                    model1.remove((Integer.parseInt(coma)) - 1); //remove do modelo na posiçao indicada, caso nao seja nulo
                                }
                                //desbugar
                                list.validate(); //para corrigir bug no visualizador
                                scrollPane.validate(); //idem
                                model1.addElement("Nada"); //...
                                model1.remove(model1.size() - 1); //...
                                //desbugar
                                salvo = false;
                                break;
                            case 3: //edita valor escolhido no orçamento EEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEE
                                System.out.println("Digite o valor do componente a ser modificado:");
                                try {
                                    coma = comando.readLine();
                                }
                                catch (IOException e){
                                    System.out.println("Erro: "+e.toString());
                                    continue;
                                }
                                if (!ver.ehInt(coma)) { System.out.println("Entrada invalida, tente novamente."); continue;} //verifica se entrada eh valida
                                //se a entrada for menor que 1, no caso querendo referenciar um no menor que o 0, ou entrada > tamanho da lista
                                if (Integer.parseInt(coma) > lista.size() || Integer.parseInt(coma) < 1) { System.out.println("Entrada fora dos limites, tente novamente."); continue; }
                                int val = Integer.parseInt(coma); //val guarda a posiçao (lembrar do -1)
                                System.out.println("Digite os valores do novo componente:");
                                System.out.println("|nome do campo| tipo do campo| custo base| frequência| preço|");
                                try {
                                    coma = comando.readLine();
                                }
                                catch (IOException e){
                                    System.out.println("Erro: "+e.toString());
                                    continue;
                                }
                                if (!ver.taLegal(coma)) { //verifica se a entrada eh valida
                                    System.out.println("Entrada invalida, tente novamente.");
                                    break;
                                }
                                StringTokenizer token1 = new StringTokenizer(coma); //tokenizer para pegar as partes da string
                                No no1 = new No(); //novo no e setando valores abaixo
                                no1.setValores(token1.nextToken(), Integer.parseInt(token1.nextToken()), Double.parseDouble(token1.nextToken()), Double.parseDouble(token1.nextToken()), Double.parseDouble(token1.nextToken()));
                                lista.remove(val - 1); //remove na posiçao indicada
                                model1.remove(val - 1); //remove do modelo na posiçao indicada
                                lista.add(val -1, no1); //adiciona na posiçao do antigo Nó
                                model1.add(val - 1, String.valueOf(lista.indexOf(no1) + 1) + "°:  " + no1.nick() + " | " + String.valueOf(no1.valor()) + " | " + String.valueOf((no1.custos())[0]) + " | " + String.valueOf((no1.custos())[1]) + " | " + String.valueOf((no1.custos())[2])); //adiciona no visualizador
                                //desbugar
                                list.validate(); //para corrigir bug no visualizador
                                scrollPane.validate(); //idem
                                model1.addElement("Nada"); //...
                                model1.remove(model1.size() - 1); //...
                                //desbugar
                                salvo = false; //seta conteudo do programa como nao salvo
                                break;
                            case 4: //salvar orçamento SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
                                boolean botao = true; //true para salvar com o nome atual, false para setar nome (em caso de haver arquivo atual)
                                String arq = arquivo; //para nao modificar a variavel principal indevidamente
                                if (lista.size() == 0) {
                                    System.out.println("Não ha nada o que salvar.");
                                    break;
                                }
                                if (!arquivo.equals("")) { //se ja houver arquivo na variavel de arquivo atual
                                    System.out.println("Deseja salvar no arquivo " + arquivo + " atual?");
                                    System.out.println("S = 0 || N = 1 ");
                                    try {
                                        coma = comando.readLine();
                                    }
                                    catch (IOException e){
                                        System.out.println("Erro: "+e.toString());
                                        continue;
                                    }
                                    if (!ver.ehInt(coma)) { System.out.println("Entrada invalida, tente novamente."); break;} //verifica se entrada eh valida
                                    int choice = 0;
                                    choice = Integer.parseInt(coma);
                                    if (choice == 0) botao = false;
                                }
                                if (botao) { //se nao houver arquivo na variavel de arquivo atual ou o usuario desejar outro nome/arquivo
                                    System.out.println("Digite o nome do arquivo a ser salvo, sem o .txt, na pasta local:");
                                    try {
                                        coma = comando.readLine();
                                    }
                                    catch (IOException e){
                                        System.out.println("Erro: "+e.toString());
                                        continue;
                                    }
                                    File file = null;
                                    file = new File(coma + ".txt");
                                    arq = coma + ".txt"; //setando variavel auxiliar para a entrada do usuario
                                    if (file.exists()) { //verifica se o arquivo ja existe, se sim, pergunta se vai sobrescrever
                                        System.out.println("O arquivo indicado, " + coma + ".txt" + "já existe, deseja sobrescrever?");
                                        System.out.println("S = 0 || N = 1 ");
                                        try {
                                            coma = comando.readLine();
                                        }
                                        catch (IOException e){
                                            System.out.println("Erro: "+e.toString());
                                            continue;
                                        }
                                        if (!ver.ehInt(coma)) { System.out.println("Entrada invalida, tente novamente."); break;} //verifica se entrada eh valida
                                        int choice = 0;
                                        choice = Integer.parseInt(coma);
                                        if (choice == 1) break;
                                    }
                                }
                                //no caso, se o programa chegou aqui, ou o arquivo existe e o usuario quer sobrescrever, ou o arquivo nao existe
                                BufferedWriter writer = null;
                                try {
                                    writer = new BufferedWriter(new FileWriter(arq));
                                    PrintWriter printer = new PrintWriter(writer);
                                    for(int i = 0; i < lista.size(); i++) {
                                        //adiciona cada componente do orçamento no arquivo
                                        printer.println(lista.get(i).nick() + " | " + String.valueOf(lista.get(i).valor()) + " | " + String.valueOf((lista.get(i).custos())[0]) + " | " + String.valueOf((lista.get(i).custos())[1]) + " | " + String.valueOf((lista.get(i).custos())[2]));
                                    }
                                    printer.close(); //fexa streams
                                    writer.close();
                                    System.out.println("Gravação completa.");
                                }
                                catch (IOException e) {
                                    System.err.println("Não pode criar/sobrescrever em " + arq);
                                    continue;
                                }
                                salvo = true; //seta conteudo do programa como salvo
                                arquivo = arq;
                                break;
                            case 5: //calcular orçamento ======================================
                                double result = 0;
                                double valor1, valor2, valor3;
                                System.out.println("o valor do seu orçamento, seguindo a equação: custo base + frequencia x preço é:");
                                for (int i = 0; i < lista.size(); i++) {
                                    valor1 = lista.get(i).custos()[0];
                                    valor2 = lista.get(i).custos()[1];
                                    valor3 = lista.get(i).custos()[2];
                                    result += valor1 + valor2 * valor3;
                                }
                                System.out.println("R$ " + result);
                                break;
                            case 6: //voltar ao menu principal
                                cnovo = false;
                                break;
                            default:
                                System.out.println("Entrada invalida, tente novamente.");
                        }
                    }
                    break;
                case 2: //carregar orçamento CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
                    if (!salvo) { //se o conteudo atual não estiver salvo, pergunta o que fazer
                        System.out.println("Você não salvou o orçamento atual, deseja continuar mesmo assim?");
                        System.out.println("S = 0 || N = 1 ");
                        try {
                            coma = comando.readLine();
                        }
                        catch (IOException e){
                            System.out.println("Erro: "+e.toString());
                        }
                        if (!ver.ehInt(coma)) { System.out.println("Entrada invalida, tente novamente."); break;} //verifica se entrada eh valida
                        int choice = 0;
                        choice = Integer.parseInt(coma);
                        if (choice == 1) break;
                    }
                    System.out.println("Digite o nome do arquivo a ser carregado, com o .txt, da pasta local:");
                    try {
                        coma = comando.readLine();
                    }
                    catch (IOException e){
                        System.out.println("Erro: "+e.toString());
                    }
                    BufferedReader file = null;
                    try{
                        file = new BufferedReader(new FileReader(coma));
                    }
                    catch(FileNotFoundException e) {
                        System.err.println("Não pode abrir " + coma);
                        continue;
                    }
                    String entrada; //para receber as strings do arquivo
                    try {
                        lista.clear(); //limpa a lista atual
                        model1.clear(); //limpa o verificador
                        while((entrada = file.readLine())!= null) {
                            StringTokenizer token = new StringTokenizer(entrada); //tokenizer para pegar as partes de string do arquivo
                            No no = new No();
                            no.setValores(token.nextToken(), Integer.parseInt(token.nextToken()), Double.parseDouble(token.nextToken()), Double.parseDouble(token.nextToken()), Double.parseDouble(token.nextToken())); //seta valores do novo no
                            lista.add(no); //adiciona no na lista de componentes
                            model1.addElement(String.valueOf(lista.indexOf(no) + 1) + "°:  " +  no.nick() + " | " + String.valueOf(no.valor()) + " | " + String.valueOf((no.custos())[0]) + " | " + String.valueOf((no.custos())[1]) + " | " + String.valueOf((no.custos())[2])); //adiciona no visualizador
                        }
                        salvo = true; //seta conteudo do programa como salvo
                        file.close();
                        System.out.println("Carregamento completo.");
                    }
                    catch (IOException e) {
                        System.out.println("Nao pode ler o arquivo");
                        System.err.println("Erro: "+e.toString());
                    }
                    //desbugar
                    list.validate(); //para corrigir bug no visualizador
                    scrollPane.validate(); //idem
                    model1.addElement("Nada"); //...
                    model1.remove(model1.size() - 1); //...
                    //desbugar
                    arquivo = coma;
                    break;
                case 3: //sair ragequit
                    chave = false;
                    break;
                default:
                    System.out.println("Entrada invalida, tente novamente.");
            }
        }
        System.exit(0);

    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JFormattedTextField jFormattedTextField1;
    private javax.swing.JFormattedTextField jFormattedTextField2;
    private javax.swing.JFormattedTextField jFormattedTextField3;
    private javax.swing.JFrame jFrame1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JList jList1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JPanel mainPanel;
    private javax.swing.JMenuBar menuBar;
    // End of variables declaration//GEN-END:variables

}
